package testpackage.java.al.excel;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;

import jxl.Sheet;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.common.utils.FileUtil;
import com.common.utils.ReadExcelTemplate;
import com.common.utils.WriteExcelTemplate;


public class T_WriteExcel {
	
	WriteExcelTemplate we = null;
	
	@Before
	public void before(){
		System.out.println("before");
		ReadExcelTemplate tr = ReadExcelTemplate.getInstance(new File("C:/Users/Administrator/Desktop/导入模板.xls"));
		we = WriteExcelTemplate.getInstance("c:/aa/2.xls");
		try {
			we.wwb = tr.getWb().createWorkbook(FileUtil.createNewFile("c:/aa/2.xls"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//		ByteArrayOutputStream b = new ByteArrayOutputStream();
////		we = WriteExcelTemplate.getInstance("c:/aa/1.xls");
//		we = WriteExcelTemplate.getInstance(b,new File("C:/Users/Administrator/Desktop/导入模板.xls"));
//		we.createNewExcel("c:/aa/2.xls", "", 1);
	}
	
	@Test
	public void t_createNewExcel(){
		we.createSheet("abc", 0);
		we.createSheet("cde", 1);
	}
	
	@Test
	public void t_createSheets(){
		String[] names = {"","a11",null,"b22","33","44"};
		we.createSheets(names, 1);
	}
	
	@Test
	public void t_addData(){
		Sheet sheet = we.createSheet("abc", 0);
		we.setColumnsWidth(sheet,2,new int[]{15,20,25,28,35});
//		we.setRowsHeight(sheet,2,new int[]{15,20,25,28,35});
		we.setRowHeight(sheet,1,150);
		we.addData(sheet, "小啊dfdsfsdfsdfs!!", 2, 5, 3,0,1);
		we.addData(sheet, "小啊dfdsfsdfsdfs!!", 3, 5, 3,1,1);
		we.fontType = "title";
		we.addData(sheet, "123!!", 4, 5, 3,3,2);
		we.addData(sheet, "小啊dfdsfsdfsdfs!!", 5, 5, 3,1,3);
		we.addData(sheet, "f!!", 6, 5, 3,4,4);
		we.fontType = "data";
		we.addNumberData(sheet, "43245", 7, 5, 3,5,5);
		we.addData(sheet, "小啊dfdsfsdfsdfs!!", 8, 5, 3,5,6);
//		we.mergeCells(sheet, 2, 4, 5, 1);
	}
	
	@Test
	public void a(){
		
	}
	@After
	public void after(){
		System.out.println("after");
		we.colseWorkBook();
		we = null;
	}
	
}
